package ULHT.LIG2N1.RC.SERVER;

import ULHT.LIG2N1.RC.VO.BlacklistVO;
import ULHT.LIG2N1.RC.VO.QuestionLimitVO;
import ULHT.LIG2N1.RC.VO.WhitelistVO;

public class GameLogicHAndler {

    private WhitelistVO whitelist;
    private BlacklistVO blacklist;

    public GameLogicHAndler() {
        this.blacklist = new BlacklistVO();
        this.whitelist = new WhitelistVO();
    }

    public GameLogicHAndler(WhitelistVO whitelist, BlacklistVO blacklist) {
        this.whitelist = whitelist;
        this.blacklist = blacklist;
    }

    public boolean isIPAllowed(String IPAdress) {
        if (blacklist.isBlacklisted(IPAdress)) {
            return false;
        } else if (whitelist.isWhitelisted(IPAdress) || whitelist.getWhitelist().isEmpty()) {
            return true;
        } else {
            return false;
        }
    }

    public void blacklistClient(String ipAdress) {
        if (whitelist.isWhitelisted(ipAdress)) {
            whitelist.removeFromWhitelist(ipAdress);
        }
        if (!blacklist.isBlacklisted(ipAdress)) {
            blacklist.addToBlacklist(ipAdress);
        }
    }

    // TODO : verificar se é fim de nivel e se respondeu a pelo menos uma
    public void checkAndScoreAnswer(int questionNumber, String answer) {
        QuestionLimitVO limit = new QuestionLimitVO();
        if (questionNumber >= 1 && questionNumber <= 15) {
            
        }
    }
}
